<template>
	<view class="content">
		<view class="avatorWrapper">
			<view class="avator">
				<image class="img" src="../../static/2222.jpg" mode="widthFix"></image>
			</view>
		</view>
		<view class="form">
			<view class="inputWrapper">
				<input class="input" type="text" v-model="phone" placeholder="请输入用户名" />
			</view>
			<view class="inputWrapper">
				<input class="input" type="password" v-model="userpassword" placeholder="请输入密码" />
			</view>
			<view class="loginBtn">
				<u-button type="btnValue" @click="primy()">登录</u-button>
			</view>
			<view class="forgotBtn">
				<text @click="zhu">注册账号</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				user: {},
				phone: '',
				userpassword: '',
				token: '',
				//用户信息
				loginInfo: {},
			}
		},
		onLoad() {

		},
		methods: {
			zhu(){
				this.$router.push('../../pages/login/zhuce')
			},
			primy() {
				uni.request({
					url: 'http://localhost:8003/userproject/user/login',
					data: {
						phone: this.phone,
						userpassword: this.userpassword
					},
					method: 'POST',
					dataType: 'json',
					success: (res) => {
						console.log(res.data.data.user)
						uni.setStorage({
							key: 'user',
							data: res.data.data.user
						}) 
						console.log(res.data)
						if (res.data.code == 20000) {
							this.$router.push('../../pages/index/index')
						} else {
							this.$router.push('../../pages/login/login')
						}
					}
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #377EB4;
		width: 100vw;
		height: 100vh;
	}

	.avatorWrapper {
		height: 30vh;
		width: 100vw;
		display: flex;
		justify-content: center;
		align-items: flex-end;
	}

	.avator {
		width: 200upx;
		height: 200upx;
		overflow: hidden;
	}

	.avator .img {
		width: 100%
	}

	.form {
		padding: 0 100upx;
		margin-top: 80px;
	}

	.inputWrapper {
		width: 100%;
		height: 80upx;
		background: white;
		border-radius: 20px;
		box-sizing: border-box;
		padding: 0 20px;
		margin-top: 25px;
	}

	.inputWrapper .input {
		width: 100%;
		height: 100%;
		text-align: center;
		font-size: 15px;
	}

	.loginBtn {
		width: 100%;
		height: 80upx;
		background: #77B307;
		border-radius: 50upx;
		margin-top: 50px;
		display: flex;
		justify-content: center;
		align-items: center;

	}

	.loginBtn .btnValue {
		color: white;
	}

	.forgotBtn {
		text-align: center;
		color: #EAF6F9;
		font-size: 15px;
		margin-top: 20px;
	}
</style>
